﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
namespace INTEX.DataBase.Tools
{
    public partial class INTEXDBC
    {
        public DataRow Convert2ABKOPF(DataRow dwInput, string ITXDBVERSION, bool IsConvert = false)
        {
            DataSet SResult = new DataSet();
            SResult = QueryABKOPF(dwInput, 0);
            DataRow dwReturn = null;
            if (SResult.Tables[0].Rows.Count > 0)
            {
                dwReturn = SResult.Tables[0].Rows[0];
            }
            else
            {
                dwReturn = SResult.Tables[0].NewRow();
            }
            switch (ITXDBVERSION)
            {
                case "YGR":
                    #region====YGR======
                    dwReturn["ABKMANDANT"] = "00";
                    dwReturn["ABKAUFKRS"] = "  ";
                    dwReturn["ABKAUFLFD"] = "000000";
                    dwReturn["ABKAUFART"] = "  ";
                    dwReturn["ABKKUNDNR"] = "00000000";
                    dwReturn["ABKWERK"] = "   ";
                    dwReturn["ABKABT"] = "   ";
                    dwReturn["ABKVTRNR"] = "        ";
                    dwReturn["ABKAEDAT"] = "0";
                    dwReturn["ABKKDAUFTNR"] = "                    ";
                    dwReturn["ABKKDAUFDAT"] = "0";
                    dwReturn["ABKKDZEICH"] = "               ";
                    dwReturn["ABKKDSB"] = "        ";
                    dwReturn["ABKARTSB"] = "        ";
                    dwReturn["ABKORDER"] = "    ";
                    dwReturn["ABKSPED"] = "   ";
                    dwReturn["ABKVERSART"] = "   ";
                    dwReturn["ABKVERPART"] = "   ";
                    dwReturn["ABKVERSADR"] = "        ";
                    dwReturn["ABKDIVADR"] = "        ";
                    dwReturn["ABKBSTADR"] = "        ";
                    dwReturn["ABKBSTDAT"] = "0";
                    dwReturn["ABKRECHADR"] = "        ";
                    dwReturn["ABKAUFTTXT1"] = "                                                                ";
                    dwReturn["ABKAUFTTXT2"] = "                                                                ";
                    dwReturn["ABKZENTREG"] = "N";
                    dwReturn["ABKTEXTE11"] = "  ";
                    dwReturn["ABKTEXTE12"] = "  ";
                    dwReturn["ABKTEXTE13"] = "  ";
                    dwReturn["ABKTEXTE14"] = "  ";
                    dwReturn["ABKTEXTE21"] = "  ";
                    dwReturn["ABKTEXTE22"] = "  ";
                    dwReturn["ABKTEXTE23"] = "  ";
                    dwReturn["ABKTEXTE24"] = "  ";
                    dwReturn["ABKAENDZL"] = "0";
                    dwReturn["ABKAENDBEN"] = "        ";
                    dwReturn["ABKAENDDAT"] = "0";
                    dwReturn["ABKNEUBEN"] = "        ";
                    dwReturn["ABKNEUDAT"] = "0";
                    dwReturn["ABKDIVARTKZ"] = "N";
                    dwReturn["ABKAGKKZ"] = " ";
                    dwReturn["ABKKDKONTR"] = "               ";
                    dwReturn["ABKSTKZL"] = "0";
                    dwReturn["ABKCOMPKZ"] = " ";
                    dwReturn["ABKFILLER"] = "                                                                       ";
                    #endregion
                    break;
                case "JLT":
                    #region====JLT========
                    dwReturn["ABKMANDANT"] = "00";
                    dwReturn["ABKAUFKRS"] = "  ";
                    dwReturn["ABKAUFLFD"] = "000000";
                    dwReturn["ABKAUFART"] = "VA";
                    dwReturn["ABKKUNDNR"] = "00000000";
                    dwReturn["ABKWERK"] = "   ";
                    dwReturn["ABKABT"] = "   ";
                    dwReturn["ABKVTRNR"] = "        ";
                    dwReturn["ABKAEDAT"] = "0";
                    dwReturn["ABKKDAUFTNR"] = "                    ";
                    dwReturn["ABKKDAUFDAT"] = "0";
                    dwReturn["ABKKDZEICH"] = "               ";
                    dwReturn["ABKKDSB"] = "        ";
                    dwReturn["ABKARTSB"] = "        ";
                    dwReturn["ABKORDER"] = "    ";
                    dwReturn["ABKSPED"] = "   ";
                    dwReturn["ABKVERSART"] = "   ";
                    dwReturn["ABKVERPART"] = "   ";
                    dwReturn["ABKVERSADR"] = "        ";
                    dwReturn["ABKDIVADR"] = "        ";
                    dwReturn["ABKBSTADR"] = "        ";
                    dwReturn["ABKBSTDAT"] = "0";
                    dwReturn["ABKRECHADR"] = "        ";
                    dwReturn["ABKAUFTTXT1"] = "                                                                ";
                    dwReturn["ABKAUFTTXT2"] = "                                                                ";
                    dwReturn["ABKZENTREG"] = "N";
                    dwReturn["ABKTEXTE11"] = "  ";
                    dwReturn["ABKTEXTE12"] = "  ";
                    dwReturn["ABKTEXTE13"] = "  ";
                    dwReturn["ABKTEXTE14"] = "  ";
                    dwReturn["ABKTEXTE21"] = "  ";
                    dwReturn["ABKTEXTE22"] = "  ";
                    dwReturn["ABKTEXTE23"] = "  ";
                    dwReturn["ABKTEXTE24"] = "  ";
                    dwReturn["ABKAENDZL"] = "0";
                    dwReturn["ABKAENDBEN"] = "        ";
                    dwReturn["ABKAENDDAT"] = "0";
                    dwReturn["ABKNEUBEN"] = "        ";
                    dwReturn["ABKNEUDAT"] = "0";
                    dwReturn["ABKDIVARTKZ"] = "N";
                    dwReturn["ABKAGKKZ"] = " ";
                    dwReturn["ABKKDKONTR"] = "               ";
                    dwReturn["ABKSTKZL"] = "0";
                    dwReturn["ABKCOMPKZ"] = " ";
                    dwReturn["ABKFILLER"] = "                                                                       ";

                    #endregion
                    break;
                default:
                    #region====ITX========
                    #endregion
                    break;
            }
            if (IsConvert)
            {
                foreach (DataColumn cm in dwInput.Table.Columns)
                {
                    if (dwInput[cm.ColumnName].ToString() == "")
                        continue;
                    if (dwReturn.Table.Columns.Contains(cm.ColumnName))
                    {
                        dwReturn[cm.ColumnName] = dwInput[cm.ColumnName];
                    }
                }
            }
            return dwReturn;
        }
        private void RefreshAPKOPF(string apkrs, string apdnr)
        {

            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryAPKOPF(apkrs, apdnr);
            double APKAENDZL = 0;
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
            }

            if (dwLocal != null)
            {
                APKAENDZL = System.Convert.ToDouble(dwLocal["APKAENDZL"].ToString()) + 1;
                dwLocal["APKAENDZL"] = APKAENDZL;
                UpdateAPKOPF(dwLocal);
            }
        }
        public void UpdateABKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE ABKOPF SET "
                + "ABKMANDANT=:ABKMANDANT,"
                + "ABKAUFKRS=:ABKAUFKRS,"
                + "ABKAUFLFD=:ABKAUFLFD,"
                + "ABKAUFART=:ABKAUFART,"
                + "ABKKUNDNR=:ABKKUNDNR,"
                + "ABKWERK=:ABKWERK,"
                + "ABKABT=:ABKABT,"
                + "ABKVTRNR=:ABKVTRNR,"
                + "ABKAEDAT=:ABKAEDAT,"
                + "ABKKDAUFTNR=:ABKKDAUFTNR,"
                + "ABKKDAUFDAT=:ABKKDAUFDAT,"
                + "ABKKDZEICH=:ABKKDZEICH,"
                + "ABKKDSB=:ABKKDSB,"
                + "ABKARTSB=:ABKARTSB,"
                + "ABKORDER=:ABKORDER,"
                + "ABKSPED=:ABKSPED,"
                + "ABKVERSART=:ABKVERSART,"
                + "ABKVERPART=:ABKVERPART,"
                + "ABKVERSADR=:ABKVERSADR,"
                + "ABKDIVADR=:ABKDIVADR,"
                + "ABKBSTADR=:ABKBSTADR,"
                + "ABKBSTDAT=:ABKBSTDAT,"
                + "ABKRECHADR=:ABKRECHADR,"
                + "ABKAUFTTXT1=:ABKAUFTTXT1,"
                + "ABKAUFTTXT2=:ABKAUFTTXT2,"
                + "ABKZENTREG=:ABKZENTREG,"
                + "ABKTEXTE11=:ABKTEXTE11,"
                + "ABKTEXTE12=:ABKTEXTE12,"
                + "ABKTEXTE13=:ABKTEXTE13,"
                + "ABKTEXTE14=:ABKTEXTE14,"
                + "ABKTEXTE21=:ABKTEXTE21,"
                + "ABKTEXTE22=:ABKTEXTE22,"
                + "ABKTEXTE23=:ABKTEXTE23,"
                + "ABKTEXTE24=:ABKTEXTE24,"
                + "ABKAENDZL=:ABKAENDZL,"
                + "ABKAENDBEN=:ABKAENDBEN,"
                + "ABKAENDDAT=:ABKAENDDAT,"
                + "ABKNEUBEN=:ABKNEUBEN,"
                + "ABKNEUDAT=:ABKNEUDAT,"
                + "ABKDIVARTKZ=:ABKDIVARTKZ,"
                + "ABKAGKKZ=:ABKAGKKZ,"
                + "ABKKDKONTR=:ABKKDKONTR,"
                + "ABKSTKZL=:ABKSTKZL,"
                + "ABKCOMPKZ=:ABKCOMPKZ,"
                + "ABKFILLER=:ABKFILLER "
                + " WHERE  "
                + "  ABKMANDANT=:ABKMANDANT AND ABKAUFKRS=:ABKAUFKRS  AND ABKAUFLFD=:ABKAUFLFD ";

            or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"].ToString();
            or1.Parameters.Add("ABKAUFKRS", OracleType.NVarChar).Value = dwData["ABKAUFKRS"].ToString();
            or1.Parameters.Add("ABKAUFLFD", OracleType.NVarChar).Value = dwData["ABKAUFLFD"].ToString();
            or1.Parameters.Add("ABKAUFART", OracleType.NVarChar).Value = dwData["ABKAUFART"].ToString();
            or1.Parameters.Add("ABKKUNDNR", OracleType.NVarChar).Value = dwData["ABKKUNDNR"].ToString();
            or1.Parameters.Add("ABKWERK", OracleType.NVarChar).Value = dwData["ABKWERK"].ToString();
            or1.Parameters.Add("ABKABT", OracleType.NVarChar).Value = dwData["ABKABT"].ToString();
            or1.Parameters.Add("ABKVTRNR", OracleType.NVarChar).Value = dwData["ABKVTRNR"].ToString();
            or1.Parameters.Add("ABKAEDAT", OracleType.NVarChar).Value = dwData["ABKAEDAT"].ToString();
            or1.Parameters.Add("ABKKDAUFTNR", OracleType.NVarChar).Value = dwData["ABKKDAUFTNR"].ToString();
            or1.Parameters.Add("ABKKDAUFDAT", OracleType.NVarChar).Value = dwData["ABKKDAUFDAT"].ToString();
            or1.Parameters.Add("ABKKDZEICH", OracleType.NVarChar).Value = dwData["ABKKDZEICH"].ToString();
            or1.Parameters.Add("ABKKDSB", OracleType.NVarChar).Value = dwData["ABKKDSB"].ToString();
            or1.Parameters.Add("ABKARTSB", OracleType.NVarChar).Value = dwData["ABKARTSB"].ToString();
            or1.Parameters.Add("ABKORDER", OracleType.NVarChar).Value = dwData["ABKORDER"].ToString();
            or1.Parameters.Add("ABKSPED", OracleType.NVarChar).Value = dwData["ABKSPED"].ToString();
            or1.Parameters.Add("ABKVERSART", OracleType.NVarChar).Value = dwData["ABKVERSART"].ToString();
            or1.Parameters.Add("ABKVERPART", OracleType.NVarChar).Value = dwData["ABKVERPART"].ToString();
            or1.Parameters.Add("ABKVERSADR", OracleType.NVarChar).Value = dwData["ABKVERSADR"].ToString();
            or1.Parameters.Add("ABKDIVADR", OracleType.NVarChar).Value = dwData["ABKDIVADR"].ToString();
            or1.Parameters.Add("ABKBSTADR", OracleType.NVarChar).Value = dwData["ABKBSTADR"].ToString();
            or1.Parameters.Add("ABKBSTDAT", OracleType.NVarChar).Value = dwData["ABKBSTDAT"].ToString();
            or1.Parameters.Add("ABKRECHADR", OracleType.NVarChar).Value = dwData["ABKRECHADR"].ToString();
            or1.Parameters.Add("ABKAUFTTXT1", OracleType.NVarChar).Value = dwData["ABKAUFTTXT1"].ToString();
            or1.Parameters.Add("ABKAUFTTXT2", OracleType.NVarChar).Value = dwData["ABKAUFTTXT2"].ToString();
            or1.Parameters.Add("ABKZENTREG", OracleType.NVarChar).Value = dwData["ABKZENTREG"].ToString();
            or1.Parameters.Add("ABKTEXTE11", OracleType.NVarChar).Value = dwData["ABKTEXTE11"].ToString();
            or1.Parameters.Add("ABKTEXTE12", OracleType.NVarChar).Value = dwData["ABKTEXTE12"].ToString();
            or1.Parameters.Add("ABKTEXTE13", OracleType.NVarChar).Value = dwData["ABKTEXTE13"].ToString();
            or1.Parameters.Add("ABKTEXTE14", OracleType.NVarChar).Value = dwData["ABKTEXTE14"].ToString();
            or1.Parameters.Add("ABKTEXTE21", OracleType.NVarChar).Value = dwData["ABKTEXTE21"].ToString();
            or1.Parameters.Add("ABKTEXTE22", OracleType.NVarChar).Value = dwData["ABKTEXTE22"].ToString();
            or1.Parameters.Add("ABKTEXTE23", OracleType.NVarChar).Value = dwData["ABKTEXTE23"].ToString();
            or1.Parameters.Add("ABKTEXTE24", OracleType.NVarChar).Value = dwData["ABKTEXTE24"].ToString();
            or1.Parameters.Add("ABKAENDZL", OracleType.NVarChar).Value = dwData["ABKAENDZL"].ToString();
            or1.Parameters.Add("ABKAENDBEN", OracleType.NVarChar).Value = dwData["ABKAENDBEN"].ToString();
            or1.Parameters.Add("ABKAENDDAT", OracleType.NVarChar).Value = dwData["ABKAENDDAT"].ToString();
            or1.Parameters.Add("ABKNEUBEN", OracleType.NVarChar).Value = dwData["ABKNEUBEN"].ToString();
            or1.Parameters.Add("ABKNEUDAT", OracleType.NVarChar).Value = dwData["ABKNEUDAT"].ToString();
            or1.Parameters.Add("ABKDIVARTKZ", OracleType.NVarChar).Value = dwData["ABKDIVARTKZ"].ToString();
            or1.Parameters.Add("ABKAGKKZ", OracleType.NVarChar).Value = dwData["ABKAGKKZ"].ToString();
            or1.Parameters.Add("ABKKDKONTR", OracleType.NVarChar).Value = dwData["ABKKDKONTR"].ToString();
            or1.Parameters.Add("ABKSTKZL", OracleType.NVarChar).Value = dwData["ABKSTKZL"].ToString();
            or1.Parameters.Add("ABKCOMPKZ", OracleType.NVarChar).Value = dwData["ABKCOMPKZ"].ToString();
            or1.Parameters.Add("ABKFILLER", OracleType.NVarChar).Value = dwData["ABKFILLER"].ToString();
            Connect2Proxy(or1);
        }
        public void SaveABKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            DataSet setResult = new DataSet();
            DataTable tbLocal = null;
            DataRow dwLocal = null;
            bool flgExist = false;
            setResult = QueryABKOPF(dwData);
            if (setResult.Tables.Count > 0)
            {
                tbLocal = setResult.Tables[0];
                if (tbLocal.Rows.Count > 0)
                {
                    flgExist = true;
                    dwLocal = tbLocal.Rows[0];
                }
                else
                {
                    dwLocal = tbLocal.NewRow();
                }
            }
            MapABKOPF(ref dwLocal, dwData);

            if (!flgExist)
            {

                InsertABKOPF(dwLocal, ITXDBVERSION);
            }
            UpdateABKOPF(dwLocal);
        }
        public DataSet QueryABKOPF(DataRow dwData, int option = 1)
        {
            DataSet setReturn = new DataSet();
            DataSet Result = new DataSet();
            DataTable tbLocal = null;
            OracleCommand or1 = OracleDB.CreateCommand();
            // APZMANDANT  APZART APZVAR APZANRKRS APZALFDNR APZSTUFE
            switch (option)
            {
                case 0:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE  ROWNUM<2 ";
                    break;
                case 1:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE  "
                    + "  ABKMANDANT=:ABKMANDANT AND ABKAUFKRS=:ABKAUFKRS AND ABKAUFLFD=:ABKAUFLFD";
                    or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"].ToString();
                    or1.Parameters.Add("ABKAUFKRS", OracleType.NVarChar).Value = dwData["ABKAUFKRS"].ToString();
                    or1.Parameters.Add("ABKAUFLFD", OracleType.NVarChar).Value = dwData["ABKAUFLFD"].ToString();
                    break;
                case 2:
                    or1.CommandText = "SELECT DISTINCT MAX(ABPSPGRD) AS ABKSPGRD,MAX(ABPGESSTA) AS ABKGESSTA, MAX(ABPLIEFDAT) AS ABKLIEFDAT,ABKMANDANT, ABKAUFKRS,ABKAUFLFD,"
                    + "MAX(ABPART) AS ABPART,MAX(FSABEZ) AS FSABEZ,MAX(LSLIEFNA) AS EXTPRODUCER,MAX(LSNAME1) AS EXTFTYNAME,MAX(ABPLIEFNR) AS ABPLIEFNR,ABPANRKR"
                    + ",ABPALFDNR FROM ABKOPF K"
                            + " RIGHT JOIN ABPOS P ON ABKAUFKRS=ABPAUFKRS AND ABKAUFLFD=ABPAUFLFD"
                            + " LEFT JOIN FSSTAMM M ON ABPART=FSART "
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                            + " WHERE ABPMANDANT=:ABPMANDANT AND ABPSPGRD=:ABPSPGRD  AND ABPERLKZ=' '"
                            + " GROUP BY ABKMANDANT,ABKAUFKRS,ABKAUFLFD,ABPANRKR,ABPALFDNR";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    or1.Parameters.Add("ABPSPGRD", OracleType.NVarChar).Value = dwData["ABPSPGRD"].ToString();
                    break;
                case 3:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE ABKMANDANT=:ABKMANDANT AND SUBSTR(ABKKDAUFTNR,1,8)=:ABKKDAUFTNR";
                    or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"].ToString();
                    or1.Parameters.Add("ABKKDAUFTNR", OracleType.NVarChar).Value = dwData["ABKKDAUFTNR"].ToString();
                    break;
               
                case 4:
                    or1.CommandText = "SELECT K.* FROM ABKOPF K "
                        + "JOIN ABPOS P ON K.ABKAUFKRS=P.ABPAUFKRS AND K.ABKAUFLFD=P.ABPAUFLFD"
                        + " JOIN FSSTAMM M ON P.ABPART=M.FSART"
                        + " WHERE FSMANDANT=:FSMANDANT AND M.FSART=:FSART";
                    or1.Parameters.Add("FSMANDANT", OracleType.NVarChar).Value = dwData["FSMANDANT"].ToString();
                    or1.Parameters.Add("FSART", OracleType.NVarChar).Value = dwData["FSART"].ToString();
                    break;
                case 5:
                    or1.CommandText = "SELECT DISTINCT MAX(ABPSPGRD) AS ABKSPGRD,MAX(ABPGESSTA) AS ABKGESSTA, MAX(ABPLIEFDAT) AS ABKLIEFDAT,ABKMANDANT, ABKAUFKRS,ABKAUFLFD,"
                    + "MAX(ABPART) AS ABPART,MAX(FSABEZ) AS FSABEZ,MAX(LSLIEFNA) AS EXTPRODUCER,MAX(LSNAME1) AS EXTFTYNAME,MAX(ABPLIEFNR) AS ABPLIEFNR,ABPANRKR"
                    + ",ABPALFDNR FROM ABKOPF K"
                            + " RIGHT JOIN ABPOS P ON ABKAUFKRS=ABPAUFKRS AND ABKAUFLFD=ABPAUFLFD"
                            + " LEFT JOIN FSSTAMM M ON ABPART=FSART "
                            + " LEFT JOIN LIEFDAT M ON LSLIEFNR=ABPLIEFNR "
                            + " WHERE ABPMANDANT=:ABPMANDANT AND ABPERLKZ=' '"
                            + " GROUP BY ABKMANDANT,ABKAUFKRS,ABKAUFLFD,ABPANRKR,ABPALFDNR";
                    or1.Parameters.Add("ABPMANDANT", OracleType.NVarChar).Value = dwData["ABPMANDANT"].ToString();
                    break;
                case 6:
                    or1.CommandText = "SELECT * FROM ABKOPF WHERE   ABKKDAUFTNR LIKE '" + dwData["ABKKDAUFTNR"].ToString().Trim()+"%'"; 
                    break;
                default:
                    break;
            }

            Result = Connect2Proxy(or1);
            if (Result.Tables.Count > 0)
            {
                tbLocal = Result.Tables[0];
                tbLocal.TableName = "ABKOPF";
            }
            setReturn.Merge(Result);
            return setReturn;
        }
        public void MapABKOPF(ref DataRow dwLocal, DataRow dwData)
        {
            BlindMap(ref dwLocal, dwData);
        }
        public void InsertABKOPF(DataRow dwData, string ITXDBVERSION = "50.24")
        {

            or1 = OracleDB.CreateCommand();
             
            or1.CommandText = "INSERT INTO ABKOPF(ABKMANDANT, ABKAUFKRS, ABKAUFLFD, ABKAUFART, ABKKUNDNR, ABKWERK, ABKABT, ABKVTRNR, ABKAEDAT, ABKKDAUFTNR, ABKKDAUFDAT, ABKKDZEICH, ABKKDSB, ABKARTSB, ABKORDER, ABKSPED, ABKVERSART, ABKVERPART, ABKVERSADR, ABKDIVADR, ABKBSTADR, ABKBSTDAT, ABKRECHADR, ABKAUFTTXT1, ABKAUFTTXT2, ABKZENTREG, ABKTEXTE11, ABKTEXTE12, ABKTEXTE13, ABKTEXTE14, ABKTEXTE21, ABKTEXTE22, ABKTEXTE23, ABKTEXTE24, ABKAENDZL, ABKAENDBEN, ABKAENDDAT, ABKNEUBEN, ABKNEUDAT, ABKDIVARTKZ, ABKAGKKZ, ABKKDKONTR, ABKSTKZL, ABKCOMPKZ, ABKFILLER)"
                + "VALUES (:ABKMANDANT, :ABKAUFKRS, :ABKAUFLFD, :ABKAUFART, '00000000', '   ', '   ', '        ', :ABKAEDAT,:ABKKDAUFTNR, :ABKKDAUFDAT, '               ', '        ', :ABKARTSB, '    ', '   ', '   ', '   ', '        ', '        ', '        ', 0, '        ', '                                                                ', '                                                                ', 'N', '  ', '  ', '  ', '  ', '  ', '  ', '  ', '  ', 0, '        ', 0, :ABKNEUBEN, :ABKNEUDAT, 'N', ' ', '               ', 0, ' ', '                                                                       ')";

            or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = dwData["ABKMANDANT"];
            or1.Parameters.Add("ABKAUFKRS", OracleType.NVarChar).Value = dwData["ABKAUFKRS"];
            or1.Parameters.Add("ABKAUFLFD", OracleType.NVarChar).Value = dwData["ABKAUFLFD"];
            or1.Parameters.Add("ABKAUFART", OracleType.NVarChar).Value = dwData["ABKAUFART"];
            or1.Parameters.Add("ABKARTSB", OracleType.NVarChar).Value = dwData["ABKARTSB"];
            or1.Parameters.Add("ABKAEDAT", OracleType.NVarChar).Value = dwData["ABKAEDAT"];
            or1.Parameters.Add("ABKKDAUFTNR", OracleType.NVarChar).Value = dwData["ABKKDAUFTNR"];
            or1.Parameters.Add("ABKKDAUFDAT", OracleType.NVarChar).Value = dwData["ABKKDAUFDAT"];
            or1.Parameters.Add("ABKNEUBEN", OracleType.NVarChar).Value = dwData["ABKNEUBEN"];
            or1.Parameters.Add("ABKNEUDAT", OracleType.NVarChar).Value = dwData["ABKNEUDAT"];
            Connect2Proxy(or1);

        }
        public void DeleteABKOPF(string client, string krs, string lfd)
        {
            OracleCommand or1;
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ABKOPF WHERE  "
                      + "  ABKMANDANT=:ABKMANDANT AND ABKAUFKRS=:ABKAUFKRS AND ABKAUFLFD=:ABKAUFLFD";
            or1.Parameters.Add("ABKMANDANT", OracleType.NVarChar).Value = client;
            or1.Parameters.Add("ABKAUFKRS", OracleType.NVarChar).Value = krs;
            or1.Parameters.Add("ABKAUFLFD", OracleType.NVarChar).Value = lfd;
            Connect2Proxy(or1);
        }
    }
}
